package com.aaa.doctor.controller.api;

import com.aaa.doctor.service.PatientService;
import com.aaa.doctor.vo.PatientVo;
import com.aaa.entity.Patient;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @author MuChengGuo
 * @date 2023/3/24 10:44
 * Description: TODO
 **/
@Api(tags = "前端 - 患者库")
@RestController
@RequestMapping("/doctor/api/patient")
public class PatientApiController {
    @Autowired
    private PatientService patientService;

    @PostMapping("/patientPage/{current}/{size}")
    @ApiOperation(value = "条件&分页查询全体患者的信息 - IPage<Patient>")
    public Result<IPage<Patient>> patientPageList(
            @ApiParam(value = "当前页码", required = true) @PathVariable Integer current,
            @ApiParam(value = "每页显示条数", required = true) @PathVariable Integer size,
            @RequestBody PatientVo patientVo) {
        return patientService.patientPageList(current, size, patientVo);
    }

    @GetMapping("/getArchiveById/{patientId}")
    @ApiOperation(value = "通过 patientId 查看此患者信息 - Patient")
    public Result<Patient> getPatientById(
            @ApiParam(value = "当前患者ID", required = true) @PathVariable String patientId) {
        return patientService.getPatientById(patientId);
    }

    @GetMapping("/getPatientByIdCard/{idCard}")
    @ApiOperation(value = "通过 身份证号(idCard) 查看此患者信息 - Patient")
    public Result<Patient> getPatientByIdCard(
            @ApiParam(value = "当前患者身份证号", required = true) @PathVariable String idCard) {
        return patientService.getPatientByIdCard(idCard);
    }

    @GetMapping("/patientAllObject/{patientId}")
    @ApiOperation(value = "通过 patientId 查看All患者信息")
    public Result<Map<String, Object>> patientAllObject(@PathVariable String patientId) {
        return patientService.patientAllObject(patientId);
    }

}
